package com.twitter.finatra.http.tests.integration.tweetexample.main

import com.twitter.conversions.StorageUnitOps._
import com.twitter.finatra.http.{HttpServer, Tls}
import com.twitter.finatra.http.filters.CommonFilters
import com.twitter.finatra.http.routing.HttpRouter
import com.twitter.finatra.http.tests.integration.tweetexample.main.controllers.{
  AdminController,
  TweetsController
}
import com.twitter.finatra.http.tests.integration.tweetexample.main.domain.{
  BarCar,
  CarMessageBodyWriter,
  FooCar,
  TweetMessageBodyReader,
  TweetMessageBodyWriter
}
import com.twitter.finatra.http.tests.integration.tweetexample.main.filters.AuthFilter
import com.twitter.finatra.http.tests.integration.tweetexample.main.modules.{
  AdminModule,
  TweetsEndpointServerModule
}

object TweetsEndpointServerMain extends TweetsEndpointServer

class TweetsEndpointServer extends HttpServer with Tls {

  override val streamRequest = true
  override val defaultMaxRequestSize = 10.megabytes

  override val modules = Seq(TweetsEndpointServerModule, AdminModule)

  override def configureHttp(router: HttpRouter): Unit = {
    router
      .register[TweetMessageBodyWriter]
      .register[TweetMessageBodyReader]
      .register[CarMessageBodyWriter, FooCar]
      .register[CarMessageBodyWriter, BarCar]
      .filter[CommonFilters]
      .add[AuthFilter, TweetsController]
      .add[AdminController]
  }
}
